#ifndef _DIRECTORYENTRY_H
#define	_DIRECTORYENTRY_H

#include <string.h>
#include "Disk.h"
/*
 * DirectoryEntry.h
 *
 * Created on March 10, 2005, 10:31 PM
 * Modified: CGP; 2/5/09
 *      Converted to C++ from Java.
 */

/** Represent the entries in a directory.
 *
 * @author chris
 */
class DirectoryEntry {
public:
    // Just the text of the file name
    static const int MAX_FILE_NAME_LENGTH = 122;

    /** For each file, we store the following information per directory entry
     *  on disk: 
     * (a) the name of the file
     * (b) one more byte for NULL
     * (c) the block number of the FCB on disk, i.e., m_FCB->GetBlockNumber()
     */
     static const int BYTES_PER_DIRECTORY_ENTRY = MAX_FILE_NAME_LENGTH+1+sizeof(int);

     unsigned int m_fcbBlockNumber; // Block number of FCB on disk.
     char m_name[MAX_FILE_NAME_LENGTH+1];

    /** Each file is represented in the directory with:
	  * (a) text name of the file; must be between 1 and MAX_FILE_NAME_LENGTH
	  * (b) a file control block number.
     */
    DirectoryEntry();

    /** 
     * @param name should be no longer than MAX_FILE_NAME_LENGTH characters.
     */
    DirectoryEntry(const char * name);

    ~DirectoryEntry();

    /** Set the FCB of this DirectoryEntry. Just updates the data member
     * of this DirectoryEntry.
     */
    void SetFCB(int fcbNumber);

    /** Generate debugging output for the data members of this Directory Entry.
     * @param newline -- if false, suppresses newline terminator following.
     */
    void Output(bool newline);
};


#endif	/* _DIRECTORYENTRY_H */

